package com.self.study.subjectsstudy.db.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.self.study.subjectsstudy.db.bean.Subjects;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lixunhuan
 * @since 2021-03-06
 */
public interface SubjectsMapper extends BaseMapper<Subjects> {

    @Select("SELECT DISTINCT subject_it FROM subjects where subject_type =#{subject_type} and level=#{level} ORDER BY id")
    List<Integer>getItems(@Param("subject_type") Integer subjectType,@Param("level") Integer level);

    @Select("SELECT * FROM subjects WHERE level =#{level} and subject_type=1 ORDER BY RAND() LIMIT 5")
    List<Subjects> getBySubjectType1(@Param("level") Integer level);

    @Select("SELECT * FROM subjects WHERE level =#{level} and subject_type=2 ORDER BY RAND() LIMIT 50")
    List<Subjects> getBySubjectType2(@Param("level") Integer level);
}
